<!-- 表格-插槽-多选查询 -->
<template>
  <div class="_pt-5 _pb-5">
    <div :style="{ maxHeight: maxHeight, overflowY: 'auto' }">
      <a-radio-group v-model="checkedList" @change="handChange">
        <a-radio
          v-for="(item, index) in options"
          :key="index"
          :style="{ display: 'block', paddingLeft: '10px', height: '24px', lineHeight: '24px' }"
          :value="item.value"
        >
          {{ item.label }}
        </a-radio>
      </a-radio-group>
    </div>

    <div class="_pl-8 _pr-8 _pt-8 tc">
      <a-button size="small" type="primary" @click="search">查询</a-button>
      <a-button size="small" class="_ml-8" @click="reset">重置</a-button>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    value: {
      type: String | Number,
      required: true,
      default: ''
    },
    options: {
      type: Array,
      required: true,
      default: () => []
    },
    maxHeight: {
      type: String,
      default: '300px'
    }
  },
  watch: {
    value: {
      handler(val) {
        this.checkedList = val
      },
      deep: true,
      immediate: true
    }
  },
  data() {
    return {
      checkedList: ''
    }
  },
  methods: {
    handChange(e) {
      const { value } = e.target
      this.$emit('input', value)
    },
    search() {
      this.$emit('search')
    },
    // 重置当前筛选条件
    reset() {
      this.$emit('input', undefined)
      this.search()
    }
  }
}
</script>

<style lang="less" scoped>
.tc {
  text-align: center;
}
</style>
